package flight

import "gitee.com/skew/mu_grpc/go/base"

type BaseFlightData struct {
	ID             uint           `gorm:"primarykey" json:"-"`
	Configuration  string         `gorm:"column:configuration;size:30"`
	Controller     string         `gorm:"column:controller;size:30" `
	Gps_satellites string         `gorm:"column:gps_satellites;type:int(11)" `
	Height         string         `gorm:"column:height;type:float" ` //无人机相对高
	Lat            string         `gorm:"column:lat;type:double" `
	Lng            string         `gorm:"column:lng;type:double"`
	Q0             string         `gorm:"column:q0;type:float" `
	Q1             string         `gorm:"column:q1;type:float"`
	Q2             string         `gorm:"column:q2;type:float"`
	Q3             string         `gorm:"column:q3;type:float"`
	SN             string         `gorm:"column:sn;size:30" `
	Source         string         `gorm:"column:source;size:30" `
	TaskID         string         `gorm:"column:task_id;type:int(11)"`
	Time           string         `gorm:"column:time;unique;NOT NULL" `
	ServerTime     base.LocalTime `gorm:"column:server_time" `
	Timestamp      string         `gorm:"column:timestamp;type:int(11)" `
	Voltage        string         `gorm:"column:voltage;size:255" `
	Vx             string         `gorm:"column:vx;type:float" `
	Vy             string         `gorm:"column:vy;type:float"`
	Vz             string         `gorm:"column:vz;type:float" `
	// 飞行模式: "Manual", "Altitude", "Position", "Function", "RTL", "TakeOff", "Landing", "Waypoint", "Locked"
	FlightMode          string  `gorm:"column:flight_mode;size:255"`
	Warns               string  `gorm:"column:warns;size:255" `
	DatalinkSignal      int     `gorm:"column:datalink_signal;type:int(11)" `
	GpsState            int     `gorm:"column:gps_state;default:1;type:int(11)" `
	NetworkSignal       int     `gorm:"column:network_signal;type:int(11)"`
	Altitude            string  `gorm:"column:altitude;default:0;type:float" ` //无人机海拔高
	Channel             int     `gorm:"column:channel;default:0;type:int(11)" `
	FlyTime             int     `gorm:"column:fly_time;default:0;type:int(11)" `      //飞行时间
	TotalFlyTime        int     `gorm:"column:total_fly_time;default:0;type:int(11)"` //飞行时间（总）
	TotalFlightDistance int     `gorm:"-"`
	FlyDis              int     `gorm:"column:fly_dis;default:0;type:int(11)" ` //飞行里程
	HomeDistance        float64 `gorm:"column:home_dis;default:0;type:float"`   //离home点的距离
	Pitch               float32 `gorm:"column:pitch;type:float"`                //俯仰角
	Roll                float32 `gorm:"column:roll;type:float"`                 //横滚角
	Head                float32 `gorm:"column:head;type:float"`                 //航向角
}
type WarnsObject struct {
	Sn                     string
	GPSWarnInfo            string
	BatteryVoltageDownInfo string
	BatteryOnlineInfo      string
	ParachuteInfo          string
	GPSSubOFWarnInfo       string
	AvdWarnInfos           []string
}

type GimbalItemObject struct {
	Pitch        float64
	Roll         float64
	Yaw          float64
	Cameras      CamerasItem
	LaserMeasure LaserMeasureItem
}
type LaserMeasureItem struct {
	MeasureTargetLongitude  float64 `json:"measure_target_longitude"`   //激光测距目标经度{"max":"180","min":"-180","unit_name":"度 / °"}
	MeasureTargetLatitude   float64 `json:"measure_target_latitude"`    //是	激光测距目标纬度{"max":"90","min":"-90","unit_name":"度 / °"}
	MeasureTargetAltitude   float64 `json:"measure_target_altitude"`    //激光测距目标海拔{"unit_name":"米 / m"}
	MeasureTargetDistance   float64 `json:"measure_target_distance"`    //激光测距距离{"unit_name":"米 / m"}
	MeasureTargetErrorState float64 `json:"measure_target_error_state"` //激光测距状态{"0":"NORMAL","1":"TOO_CLOSE","2":"TOO_FAR","3":"NO_SIGNAL"}
}
type CamerasItem struct {
	PayloadIndex      string  // 相机索引
	CameraMode        int     // 相机模式 0—拍照 1-录像
	PhotoState        int     // 拍照状态 0—空闲 1—拍照中
	ScreenSplitEnable int     // 分屏是否使能, 0---关闭 1--开启
	RecordingState    int     // 录像状态,0----空闲 ,1----录像中
	ZoomFactor        float32 // 变焦倍数
	ZoomFocusState    int     // "0":"空闲","1":"对焦中","2":"对焦成功","3":"对焦失败"
	IrMeteringMode    int     // {"0":"关闭测温","1":"点测温","2":"区域测温"}
	VideoType         string  // 相机镜头类型
	ThermalObject     Thermal `json:"Thermal"` // 红外镜头信息
}
type Thermal struct {
	IrZoomFactor         float32        // 红外变焦倍数
	X                    float64        // 测温点坐标x，以镜头的左上角为坐标中心点，水平方向为x{"max":1,"min":0}
	Y                    float64        // 测温点坐标y，以镜头的左上角为坐标中心点，竖直方向为y{"max":1,"min":0}
	Temperature          float64        // 测温点的温度
	IRMeteringAreaObject IRMeteringArea `json:"IrMeteringArea"` // 红外测温区域
}

type IRMeteringArea struct {
	X                   float64          // 测温区域左上角点坐标x {"max":1,"min":0}
	Y                   float64          // 测温区域左上角点坐标y {"max":1,"min":0}
	Width               float64          // 测温区域宽度{"max":1,"min":0}
	Height              float64          // 测温区域高度{"max":1,"min":0}
	AverTemperature     float64          // 测温区域平均温度
	MinTemperaturePoint TemperaturePoint // 测温区域最低温度点
	MaxTemperaturePoint TemperaturePoint // 测温区域最高温度点
}

type LiveviewWorldRegion struct {
	Bottom float64 `json:"bottom"`
	Left   float64 `json:"left"`
	Right  float64 `json:"right"`
	Top    float64 `json:"top"`
}

type TemperaturePoint struct {
	X           float64 // 温度点坐标x {"max":1,"min":0}
	Y           float64 // 温度点坐标y {"max":1,"min":0}
	Temperature float64 // 温度点的温度
}

type IrMeteringPoint struct {
	X           float64 `json:"x"`
	Y           float64 `json:"y"`
	Temperature float64 `json:"temperature"`
}
type IrMeteringArea struct {
	X               float64 `json:"x"`
	Y               float64 `json:"y"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	AverTemperature float64 `json:"aver_temperature"`
}
type MinTemperaturePoint struct {
	X           float64 `json:"x"`
	Y           float64 `json:"y"`
	Temperature float64 `json:"temperature"`
}
type MaxTemperaturePoint struct {
	X           float64 `json:"x"`
	Y           float64 `json:"y"`
	Temperature float64 `json:"temperature"`
}

type Payloads struct {
	Category       string `xorm:"varchar(64) not null  comment('负载类别')" json:"category"` ///1 喊话器，2 探照灯，3抛投器，4激光雷达
	PayloadName    string `xorm:"payload_name varchar(64)  null comment('负载序名称')" json:"payload_name"`
	MountPosition  string `xorm:"mount_position varchar(64) default 'main' comment('挂载位置')" json:"mount_position"`
	PayloadModelId int64  `xorm:"payload_model_id bigint(20) default 'main' comment('挂载位置')" json:"payload_model_id"`
}
